//
//  MBDNetworkManager.swift
//  MasterBoy
//
//  Created by kyson on 2023/6/28.
//

import Foundation
import Alamofire
import Toast_Swift

let networkManager = NetworkReachabilityManager(host: "www.apple.com")


class MBDNetworkManager {
    
    static let shared = MBDNetworkManager()
    
    func startListening(){
        networkManager!.startListening { status in
            var message = ""
            
            let appDelegate = UIApplication.shared.delegate as! AppDelegate

            switch status {
            case .unknown:
                message = "未知网络,请检查..."
                
                appDelegate.window?.rootViewController?.view.makeToast(message,position: .center)
            case .notReachable:
                message = "无法连接网络,请检查..."
                appDelegate.window?.rootViewController?.view.makeToast(message,position: .center)
            case .reachable(.cellular):
                message = "蜂窝移动网络,注意节省流量..."
                appDelegate.window?.rootViewController?.view.makeToast(message,position: .center)

            case .reachable(.ethernetOrWiFi):
                //                message = "WIFI-网络,使劲造吧..."
                message = "已切换到WIFI网络"
            }

        }
    }
    
}
